package dev.ece.suit.loader.models.ms3d;

import org.lwjgl.opengl.GL11;

import dev.ece.core.vertex.EBO;
import dev.ece.suit.loader.Face;
import dev.ece.suit.loader.Mesh;

public class MS3DMesh extends Mesh {

	public MS3DMesh(int[] faceIndice, int materialIndex) {
		super(faceIndice, materialIndex);
	}

	protected void fillData(MS3DVertex[] vertice, MS3DTriangle[] triangles) {
		int[] v_indice = null;
		MS3DTriangle triangle = null;
		MS3DVertex ms3dvertex = null;
		for(int i=0; i<this.getFaceIndice().length; i++) {
			triangle = triangles[this.getFaceIndice()[i]];
			v_indice = triangle.getIndice();
			for(int j=0; j<3; j++) {
				ms3dvertex = vertice[v_indice[j]];
				this.getVertice().add(ms3dvertex);
				this.getNormals().add(triangle.getNormals()[j]);
				this.getTextureCoords().add(triangle.getUvs()[j]);
				this.getBoneindice().add(ms3dvertex.getBoneIds());
				this.getWeights().add(ms3dvertex.getWeights());
			}
		}
	}
	
	@Override
	protected EBO createRenderEBO(Face[] faces) {
		return null;
	}

	@Override
	protected void render() {
		GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.getCount());
	}

}
